package com.chat.controller.user;


import com.chat.dto.CarpoolOrderDTO;
import com.chat.result.PageResult;
import com.chat.result.Result;
import com.chat.service.CarpoolOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/order")
@Slf4j
@Api(tags = "拼车订单接口")
public class CarpoolOrderController {
    @Autowired
    private CarpoolOrderService carpoolOrderService;

    @PostMapping("/addCarpool")
    @ApiOperation("添加拼车订单")
    public Result addCarpool(@RequestBody CarpoolOrderDTO carpoolOrderDTO) {
        log.info("添加拼车订单：{}",carpoolOrderDTO);
        carpoolOrderService.addCarpool(carpoolOrderDTO);
        return Result.success();
    }

    @GetMapping("/getCarpool")
    @ApiOperation("查询拼车订单")
    public Result<PageResult> getCarpool(Integer page, Integer pageSize) {
        log.info("查询第{}页，每页{}数据",page,pageSize);
        PageResult pageResult = carpoolOrderService.getCarpool(page,pageSize);
        return Result.success(pageResult);
    }


}
